package com.atguigu.mediator.smarthouse;

import java.util.HashMap;

//具体的中介者类
public class ConcreteMediator extends Mediator {
	
	private HashMap<String, Colleague> colleagueMap;
	private HashMap<String, String> interMap;
	
	public ConcreteMediator() {
		colleagueMap = new HashMap<String, Colleague>();
		interMap = new HashMap<String, String>();
	}

	@Override
	public void register(String name, Colleague colleague) {
		colleagueMap.put(name,colleague);
		
		if (colleague instanceof Alarm) {
			interMap.put("Alarm",name);
		}
	}

	//具体的中介者的核心方法
	//1.根据得到的消息，完成对应的任务
	//2.中介者在这个方法，协调各个具体的同事对象，完成任务
	@Override
	public void getMessage(int stateChange, String name) {
		if (colleagueMap.get(name) instanceof Alarm) {
			if (stateChange == 0) {
				System.out.println("1111");
			}else {
				System.out.println("222");
			}
		}
	}

	@Override
	public void sendMessage() {
		
	}

}
